<?php
/**
 * tmaic.com 
 * ============================================================================
 * * 版权所有 2020-2030 tmaic，并保留所有权利。
 * 网站地址: http://www.tmaic.com；
 * ----------------------------------------------------------------------------
 * 这不是一个自由软件！您只能在不用于商业目的的前提下对程序代码进行修改和
 * 使用；不允许对程序代码以任何形式任何目的的再发布。
 * ============================================================================
 * $Author: pangxianfei
 * $email:421339244@qq.com
 * $phone:18929142226
 * $date 2020-11-13
*/
namespace App\Http\Middleware;

use Closure;
use Cache;	
class Menu
{
    public function handle($request, Closure $next)
    {
         
        //左侧菜单
        view()->composer('admin.layout', function ($view) {
			$menus = cache()->remember('admin.layout.menus', 0, function (){ 	
				return \App\Models\Permission::with([
                'childs' => function ($query) {
                    return $query->with('icon');
                }
                , 'icon'])->where(['parent_id' => 0, 'status' => 1])->orderBy('sort', 'asc')->get();
				
			});	
			$view->with('menus', $menus);	
				
            //$unreadMessage = \App\Models\Message::where('read', 1)->where('accept_uuid', auth()->user()->uuid)->count();
            //$view->with('unreadMessage', $unreadMessage);
            

        });

	 
	 
        return $next($request);
    }
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
}
